<?php namespace Common\Model;
use Hdphp\Model\Model;

class Order extends Model{
	
	protected $table = "360mall_order";
//	protected $validate = array(
//	 array("o_number","required","不能重fu",3,3),
//	
//	);

	public function store($tid){
//	if(!$this->create()) return false;
		//订单号
		if(isset($_SESSION['uid'])&&!empty($_SESSION['cart']['goods'])){
		//价格总计
		$total = $_SESSION['cart']['total'];
		//状态
		$data = array(
		   'o_number'=>$tid,
		   'o_total'=>$total,
		   'o_status'=>"未付款",
		   'o_uid'=>$_SESSION['uid'],
		   'o_time'=>time(),
		);
	      $oid =   $this->add($data);
		  $OrderList = new \Common\Model\OrderList;	
		  foreach ($_SESSION['cart']['goods'] as $k => $v) {
		    $i = Db::table("360mall_goods")->where("g_id",$v['id'])->pluck("g_number");
		  	$LIST = array(
			  'ol_njum'=>$v['num'],
			  'ol_gid'=>$v['id'],
			  'o_info'=>$v['options'],
			  'ol_oid'=>$oid,
			  'ol_price'=>$v['total'],
			  'ol_number'=>$i,
			);
			 $OrderList->add($LIST);
		  }
		 
		} return true;
	}
}